import java.util.Arrays;

public class Test1 {
    public static int maxSubArray(int[] nums) {
        int pre=0,maxAns=nums[0];
        for(int x:nums){
            pre=Math.max(pre+x,x);
            maxAns=Math.max(maxAns,pre);
        }
        return maxAns;
    }

    public static void main(String[] args) {
        int[] nums={-78,454,-3,75,-34,11,2};
        int n=maxSubArray(nums);
        System.out.println(n);
    }
}
